<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>

</head>
<body>

<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>
<input id="inp1" type="text" value="xx" onchange="getf1()" /><input id="res1" type="text" value="xx" /><br />
<input id="inp2" type="text" value="xx" onchange="getf2()"/><input id="res2" type="text" value="xx" /><br />
</body>
<script>
table = 'product' ;
function showf1(ans) {
 if (ans[0].desc !== "undefined") {
  document.getElementById('res1').value = ans[0].desc;
  $("#inp2").attr("disabled",false);
  $("#inp1").attr("disabled",true);
  document.getElementById('inp2').focus();
 } else {
  document.getElementById('inp1').focus();
 }  
}
function showf2(ans) {
 if (ans[0].desc !== "undefined") {
  document.getElementById('res2').value = ans[0].desc;
  $("#inp2").attr("disabled",true);
 } else {
  document.getElementById('inp2').focus();
 }  
}
function fileit() {
 aset = {} ;
 aset.url ="https://api.mongolab.com/api/1/databases/cpa/collections/" + table + "?apiKey=t5zMkuO6oTA961rXLDGtTOoCo0FpLrHx&";
 aset.data =JSON.stringify( {"_id" : document.getElementById("inp1").value  , "desc" : document.getElementById("inp2").value } );
 aset.type = 'POST' ;
 aset.contentType = 'application/json' ;
 $.ajax(aset).success(showit);
}
function getf1() {
 url ="https://api.mongolab.com/api/1/databases/cpa/collections/" + table + "?apiKey=t5zMkuO6oTA961rXLDGtTOoCo0FpLrHx&";
 var q = { '_id':  document.getElementById("inp1").value };
 url = url + "&q=" +  JSON.stringify(q);
 $.getJSON(url,showf1);
}
function getf2() {
 url ="https://api.mongolab.com/api/1/databases/cpa/collections/" + table + "?apiKey=t5zMkuO6oTA961rXLDGtTOoCo0FpLrHx&";
 var q = { '_id':  document.getElementById("inp2").value };
 url = url + "&q=" +  JSON.stringify(q);
 $.getJSON(url,showf2);
}

$("button").attr("disabled", true);
$("input[type=text]").attr("disabled", true);
$("#inp1").attr("disabled",false);
document.getElementById('inp1').focus();  

</script>
</html>